function [ normalizedImSet ] = imNormalizer(imageSet, imageFeatures, boundaryAvgTarget )
%imNormalizer filters the images with a gaussian blur and than normalizes
%   Detailed explanation goes here

% % Below is the code to normalize only within the 4 degree circle    
% % Smooth the images with a Gaussian blur
% % Step 1: Create Gaussian filter w/ fspecial
% SIGMA = 4; % Increasing sigma increases the blur.
% FILTER_SIZE = [15 15];
% smoothingFilter = fspecial('gaussian', FILTER_SIZE, SIGMA);
% imageSet.blueIm  = imfilter(imageSet.blueIm, smoothingFilter);
% imageSet.otherIm = imfilter(imageSet.otherIm, smoothingFilter);
% imageSet.redIm = imfilter(imageSet.redIm, smoothingFilter);
% 
% 
% % Re-normalize after blur
% K = 1/boundaryAvgTarget;
% 
% blueBoundaryAvg = mean(imageSet.blueIm(imageFeatures.iMacBoundary));
% imageSet.blueIm(imageFeatures.iMacBoundary) = ...
%     imageSet.blueIm(imageFeatures.iMacBoundary)./(K*blueBoundaryAvg);
% imageSet.blueIm(imageFeatures.iMacRegion) = ...
%     imageSet.blueIm(imageFeatures.iMacRegion)./(K*blueBoundaryAvg);
% 
% otherBoundaryAvg = mean(imageSet.otherIm(imageFeatures.iMacBoundary));
% imageSet.otherIm(imageFeatures.iMacBoundary) = ...
%     imageSet.otherIm(imageFeatures.iMacBoundary)./(K*otherBoundaryAvg);
% imageSet.otherIm(imageFeatures.iMacRegion) = ...
%     imageSet.otherIm(imageFeatures.iMacRegion)./(K*otherBoundaryAvg);
% 
% redBoundaryAvg = mean(imageSet.redIm(imageFeatures.iMacBoundary));
% imageSet.redIm(imageFeatures.iMacBoundary) = ...
%     imageSet.redIm(imageFeatures.iMacBoundary)./(K*redBoundaryAvg);
% imageSet.redIm(imageFeatures.iMacRegion) = ...
%     imageSet.redIm(imageFeatures.iMacRegion)./(K*redBoundaryAvg);
% 
% normalizedImSet.blueIm = imageSet.blueIm;
% normalizedImSet.otherIm = imageSet.otherIm;
% normalizedImSet.redIm = imageSet.redIm;

% % Smooth the images with a Gaussian blur
% % Step 1: Create Gaussian filter w/ fspecial
% SIGMA = 4; % Increasing sigma increases the blur.
% FILTER_SIZE = [15 15];
% smoothingFilter = fspecial('gaussian', FILTER_SIZE, SIGMA);
% imageSet.blueIm  = imfilter(imageSet.blueIm, smoothingFilter);
% imageSet.otherIm = imfilter(imageSet.otherIm, smoothingFilter);
% imageSet.redIm = imfilter(imageSet.redIm, smoothingFilter);


% Re-normalize after blur
K = 1/boundaryAvgTarget;

% Determine average pixel value along 4 degree circle for each image
blueBoundaryAvg = mean(imageSet.blueIm(imageFeatures.iMacBoundary));
otherBoundaryAvg = mean(imageSet.otherIm(imageFeatures.iMacBoundary));
redBoundaryAvg = mean(imageSet.redIm(imageFeatures.iMacBoundary));

% Normalize image so 1/2 on 4 degrees for each image
imageSet.blueIm = imageSet.blueIm ./(K*blueBoundaryAvg);
imageSet.otherIm = imageSet.otherIm ./(K*otherBoundaryAvg);
imageSet.redIm = imageSet.redIm ./ (K*redBoundaryAvg);

normalizedImSet.blueIm = imageSet.blueIm;
normalizedImSet.otherIm = imageSet.otherIm;
normalizedImSet.redIm = imageSet.redIm;


end

